<template>
	<div>
		<common-top :mainTitle="global.triageName" separator="——" subtitle="分诊记录"></common-top>
		<div class="triages">
			<el-row>
				<el-col>
					<el-date-picker
					v-model="timeRange"
					type="datetimerange"
					range-separator="至"
					start-placeholder="开始日期"
					end-placeholder="结束日期">
					</el-date-picker>
					<el-button type="primary" @click="getRecords">确定</el-button>
				</el-col>
			</el-row>
			<el-row class="records">
				<el-col>
					<el-table
						:data="recordList"
						border
						style="width:100%">
						<el-table-column
							label="日期"
							width="100">
							<template slot-scope="scope">
								<span>{{scope.row.lastTime}}</span>
							</template>
						</el-table-column>
						<el-table-column
							label="姓名"
							width="80">
							<template slot-scope="scope">
								<router-link :to="'/caseDetail/'+scope.row.recordUUID" target="_blank">
									<span>{{scope.row.recordName}}</span>
								</router-link>
								<!-- <br><span>{{scope.row.recordCard}}</span> -->
							</template>
						</el-table-column>
						<el-table-column
							label="性别"
							width="40">
							<template slot-scope="scope">
								<span>{{scope.row.recordSex}}</span>
							</template>
						</el-table-column>
						<el-table-column
							label="年龄"
							width="50">
							<template slot-scope="scope">
								<span>{{scope.row.recordAge}}</span>
							</template>
						</el-table-column>
						<el-table-column
							label="护理诊断"
							width="160">
							<template slot-scope="scope">
								<span>{{scope.row.nurseDisease}}</span>
							</template>
						</el-table-column>
						<el-table-column
							label="意识"
							width="100">
							<template slot-scope="scope">
								<span>{{scope.row.recordSense}}</span>
							</template>
						</el-table-column>
						<el-table-column
							label="生命体征"
							width="145">
							<template slot-scope="scope">
								<span>T:{{scope.row.recordTemperature}}℃</span><br>
								<span>P:{{scope.row.recordPulseRate}}次/分</span><br>
								<span>R:{{scope.row.recordBreathRate}}次/分</span><br>
								<span>Bp:{{scope.row.recordSBP}}/{{scope.row.recordDBP}}mmHg</span>
							</template>
						</el-table-column>
						<el-table-column
							label="病情分级"
							width="50">
							<template slot-scope="scope">
								<span>{{grades[scope.row.recordLight]}}</span>
							</template>
						</el-table-column>
						<el-table-column
							label="MEWS"
							width="65">
							<template slot-scope="scope">
								<span v-if="scope.row.mews!='-1'">{{scope.row.mews}}</span>
								<span v-if="scope.row.mews=='-1'">/</span>
							</template>
						</el-table-column>
						<el-table-column
							label="分诊区域"
							width="100">
							<template slot-scope="scope">
								<span>{{scope.row.handlePlace}}</span>
							</template>
						</el-table-column>
						<el-table-column
							label="去向"
							width="100">
							<template slot-scope="scope">
								<span>{{scope.row.sendDept}}</span>
							</template>
						</el-table-column>
						<el-table-column
							label="联系电话"
							width="100">
							<template slot-scope="scope">
								<span>{{scope.row.recordTel}}</span>
							</template>
						</el-table-column>
						<el-table-column
							label="地址">
							<template slot-scope="scope">
								<span>{{scope.row.recordAddress}}</span>
							</template>
						</el-table-column>
						<el-table-column
							label="分诊护士"
							width="100">
							<template slot-scope="scope">
								<span>{{scope.row.nurse}}</span>
							</template>
						</el-table-column>
						
					</el-table>
				</el-col>
			</el-row>
		</div>
	</div>
</template>
<script type="text/javascript">
	import CommonTop from '@/components/CommonTop'
	export default{
		name:"Triages",
		components: {CommonTop},
		data(){
			return {
				timeRange:[new Date((new Date()).getTime()-3600*1000*24*1),new Date()],
				curUser:{},
				recordList:[],
				grades:{
					"1":"Ⅳ级",
					"2":"Ⅲ级",
					"3":"Ⅱ级",
					"4":"Ⅰ级"
				}
			}
		},
		methods:{
			getRecords:function(){
				var vm = this;
				var startTime = new Date();
				var lastTime = new Date((new Date()).getTime()-3600*1000*24*1);
				if (vm.timeRange.length==2) {
					startTime = vm.timeRange[0];
					lastTime = vm.timeRange[1];
				}
				var hospitalCode = vm.curUser.hospitalCode;
				this.$axios.getTriage(vm.commonUtil.dateFormat(startTime,"yyyy-MM-dd hh:mm:ss"),vm.commonUtil.dateFormat(lastTime,"yyyy-MM-dd hh:mm:ss"),hospitalCode).then(function(res){
					if (res.data&&res.data.data) {
						vm.recordList = res.data.data;
					}
				},function(res){
					console.log("error:"+res);
				});
			}
		},
		mounted(){
			if (this.$cookies.get("curUser")) {
				this.curUser = this.$cookies.get("curUser");
			}
		},
	}
</script>
<style type="text/css" scoped>
	.triages{
		line-height: 35px;
		margin-top: 20px;
	}
	.records{
		margin-top: 20px;
		margin-left: 10px;
		margin-right: 10px;
		margin-bottom: 120px;
		text-align: left;
	}
	.records a:link{
		text-decoration: none;
	}
</style>